﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Data;

namespace PJ.Business
{
    /// <summary>
    /// EntityExtension class
    /// </summary>
    /// <typeparam name="OD">Inner data object</typeparam>
    public abstract class EntityExtension<OD> : Entity<OD>, IEntityExtension
        where OD : IEntityExtensionData
    {
        //        private IEntityService m_OwnerService;
        //private IEntity m_Owner;

        public EntityExtension(OD data) //, IEntityService ownerService)
            : base(data)
        {
            //if (ownerService == null)
            //    throw new ArgumentNullException();
            //m_OwnerService = ownerService;
        }

        public EntityExtension(/*IEntityService ownerService*/)
        {
            //if (ownerService == null)
            //    throw new ArgumentNullException();
            //m_OwnerService = ownerService;
        }

        public string OwnerId
        {
            get { return Id; }
            set { Id = value; }
        }

        /*
        protected IEntityService OwnerService { get { return m_OwnerService; } }


        public IEntity Owner
        {
            get
            {
                if (m_Owner == null && !string.IsNullOrEmpty(OwnerId))
                    Owner = OwnerService.FindById(OwnerId);
                return m_Owner;
            }
            set
            {
                if (value != m_Owner)
                {
                    m_Owner = value;
                    if (value == null)
                        OwnerId = null;
                    else
                        OwnerId = value.GlobalId;
                }
            }
        }
        public override void Dispose()
        {
            m_Owner = null;
            m_OwnerService = null;
            base.Dispose();
        }
         * */
    }

}

